<?php
/*! \brief
 * This is WFDomFactory class
 * This is the Simple Factory Class that create relative Dom Class
 * \author William Su
 */
class WFDomFactory
{
    private $objFramework;
    private static $instance;
    /**
     * @return WFFile
     */
    public function __construct($objFramework){
        $this->objFramework = $objFramework;
    }
    public static function getDirnameFile(){
        if(! isset(self::$instance[__FUNCTION__])){
            self::$instance[__FUNCTION__] = dirname(__FILE__);
        }
        return self::$instance[__FUNCTION__];
    }
    /**
     * @return WFSimplexml
     */
    public function getSimplexml($strPathOrDom = null){
        if(! isset(self::$instance[__CLASS__][__FUNCTION__])){
            require_once (self::getDirnameFile() . '/Simplexml.php');
        }
        self::$instance[__CLASS__][__FUNCTION__] = new WFSimplexml($strPathOrDom, $this->objFramework);
        return self::$instance[__CLASS__][__FUNCTION__];
    }
    /**
     * @return WFDOMDocument
     */
    public function getDOMDocument($strVersion = '1.0',$strEncoding = 'UTF-8'){
        if(! isset(self::$instance[__CLASS__][__FUNCTION__])){
            require_once (self::getDirnameFile() . '/DOMDocument.php');
        }
        self::$instance[__CLASS__][__FUNCTION__] = new WFDOMDocument($strVersion, $strEncoding);
        return self::$instance[__CLASS__][__FUNCTION__];
    }
}